#ifndef _RECORD_H
#define _RECORD_H
#include "includes.h"




typedef enum 
{
    EVT_START_CHG = 0,
    EVT_START_DSG =1,
    EVT_UV =3,
    EVT_OV = 5 ,
    EVT_TEMP_ERR = 6 ,
    EVT_CURR_ERR = 7,
    EVT_HARD_ERR = 8,
    EVT_CHG_OV_PROTECT  =20,
    EVT_CHG_OVR_PROTECT,
    EVT_DSG_UV_PROTECT,
    EVT_DSG_UVR_PROTECT,
    EVT_VDIFF_PROTECT,
    EVT_VDIFFR_PROTECT,
    EVT_OTC_PROTECT,
    EVT_OTCR_PROTECT,
    EVT_OTD_PROTECT,
    EVT_OTDR_PROTECT,
    EVT_UTC_PROTECT,
    EVT_UTCR_PROTECT,
    EVT_UTD_PROTECT,
    EVT_UTDR_PROTECT,
    EVT_OCD_PROTECT,
    EVT_OCDR_PROTECT,
    EVT_OCC_PROTECT,
    EVT_OCCR_PROTECT,
    EVT_MOST_PROTECT,
    EVT_MOSTR_PROTECT,
    EVT_SOCF_PROTECT,
    EVT_SOCFR_PROTECT
}EVT_en;



typedef struct 
{

    uint8_t id[2];                      //履历编号
    uint8_t hTimeStamp[4];              //事件时间戳
    uint8_t rTimeStamp[4];              //实时时间戳
    uint8_t evtType;                    //事件类型
    uint8_t sumVolt[2];                 //总电压
    uint8_t curr[2];                    //电流
    uint8_t batHighTemp;                //电池最高温度
    uint8_t resCap[2];                  //剩余容量
    uint8_t fcc[2];                     //满充容量
    uint8_t batState[2];                //电池状态
}RecordData_t;

typedef struct 
{
    uint16_t itemsum;                   //记录当前已记录的总条数
    //uint16_t curPos;                    //当前flash中存的编号位置
    uint32_t nextWriteAddress;          //记录下一条记录要写的flash地址


}RecordDCB_t;



uint8_t RecordRead(uint8_t id,uint8_t *rec);
uint16_t RecordGetItems();
void RecWriteFlash(EVT_en e);
void RecDcbInit();







#endif
